import { request } from '@umijs/max';
import { Button, message } from 'antd';
import React from 'react';

const ButtonComponents: React.FC<API.InterfaceInfo> = (props) => {
  const handleClick = async () => {
    const res = await request(props.url as string, {
      method: props.method,
      headers: {
        token: localStorage.getItem('token') || '',
      },
    });
    if (String(res.code) === '200') {
      message.success('训练成功');
    } else {
      message.info('训练失败');
    }
  };
  return <Button onClick={() => handleClick()}>开始训练</Button>;
};

export default ButtonComponents;
